package cn.chenxinjie.hrm.config;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author 陈鑫杰
 * @date 2022/3/16 10:32
 */
@Component
public class RabbitComponent {
    //定义邮件的队列名字
    public static final String QUEUE_NAME_EMAIL = "queue_name_email";
    //定义短信的队列名字
    public static final String QUEUE_NAME_SMS = "queue_name_SMS";
    //站内信队列
    public static final String QUEUE_NAME_SYSTEM_MESSAGE = "queue_name_system_message";

    @RabbitListener(queues = {QUEUE_NAME_EMAIL})
    public void sendSms(String name, Channel channel, Message message) throws IOException {
        long tag = message.getMessageProperties().getDeliveryTag();
        channel.basicAck(tag, false);
        String msg = "亲爱的用户，我们课程【"+name+"】课程已经上线，请查收。www.itsource.cn【源码时代】";
        System.out.println(msg);
    }
}
